package com.lcb.spring.config;


import com.lcb.spring.bean.*;
import com.lcb.spring.compentscan.User;
import com.lcb.spring.condition.LcbCondition;
import com.lcb.spring.factorybean.LcbFactoryBean;
import com.lcb.spring.importselector.LcbBeanDefinitionRegister;
import com.lcb.spring.importselector.LcbImportSelector;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @Author: 刘长柏
 * @Date: 2021-03-09
 * @Description: 主配置类
 */
@Configuration
//排除
@ComponentScan(basePackages = {"com.lcb.spring.compentscan"}, excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ANNOTATION, value = {Component.class}),
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = User.class)
})
@Import(value = {Test1.class, Test2.class, LcbImportSelector.class, LcbBeanDefinitionRegister.class})
public class MainConfig {


    @Bean
    public LcbFactoryBean lcbFactoryBean() {
        return new LcbFactoryBean();
    }

    @Bean(initMethod = "init", destroyMethod = "destroy")
    public Car car() {
        return new Car();
    }

    @Bean
    //@Scope
    //@Lazy
    public Person person() {
        return new Person();
    }

    //@Bean
    public Aspect aspect() {
        return new Aspect();
    }

    @Bean
    @Conditional(value = LcbCondition.class)
    public Log log() {
        return new Log();
    }


}
